﻿
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "UniIdentity.h"
#include "DbDataSchema.h"
#include "DbObjectUtils.h"
#include "NdbObjectSchematic.h"
#include "IGraphicsNodeStyleAndMaterialCustomizer.h"

#include "GRepModule.h"

namespace gcmp
{
    class IElement;
    class ElementId;
    class IModelView;
    class RuntimeId;
}

namespace Sample
{
    // 【视图比例动态样式】命令对应的IGraphicsNodeStyleAndMaterialCustomizer实现：演示如何根据视图比例动态刷新图元的显示样式，该命令需要配合【刷新显示样式】命令。
    // 选中图元运行该命令后，在【视图比例】改为大于或小于1:50后，运行【刷新显示样式】命令可以看到有显示样式的改变。
    class ScaleGraphicsNodeStyleCustomizer : public gcmp::NdbObjectSchematic, public gcmp::IGraphicsNodeStyleAndMaterialCustomizer
    {
        DBOBJECT_DATA_BEGIN_AND_QUICK_CAST_FROM(Sample, ScaleGraphicsNodeStyleCustomizer, gcmp::NdbObjectSchematic, 122929D2 - 4569 - 4D02 - B84F - CA43E7DB0E58, GRepModule, gcmp::IGraphicsNodeStyleAndMaterialCustomizer)
            DATA_TRANSIENT(gcmp::IElement*, pOwnerElement)
            DBOBJECT_DATA_END
    public:
        ScaleGraphicsNodeStyleCustomizer(gcmp::IElement* pElement);
        virtual bool SetOwnerElement(gcmp::IElement* pOwnerElement) override { m_pOwnerElement = pOwnerElement; return true; }
        virtual gcmp::IElement* GetOwnerElement() override { return m_pOwnerElement; }
        virtual const gcmp::IElement* GetOwnerElement() const override { return m_pOwnerElement; }
        virtual NdbObject* GetTopOwnerObject() const override { return nullptr; }
        virtual gcmp::IGraphicsNodeStyleAndMaterialCustomizer::CustomizationInfo GetCustomizationInfo(const gcmp::IModelView* pModelView) const override;
    };
}

